Imports MyClasses
Imports System.Data.SqlClient

Public Class DTempPurchase

    Public Shared Function GetRecords(ByVal VendorNm As Integer, ByVal ItemNm As String) As DataTable
        Dim StrSql As String = ""
        Try
            If VendorNm = 0 And ItemNm = "" Then
                StrSql = " SELECT temp.DumId,temp.DumDate,temp.ItemId,CLRcode,Qty,MRP,temp.VendorId,I.ItemName,V.VendorName" & _
                         " FROM tTempPurchase temp, mpItem I, mpVendor V" & _
                         " WHERE temp.Status='A' AND temp.ItemId=I.ItemId AND temp.VendorId=V.VendorId "
            ElseIf VendorNm <> 0 And ItemNm = "" Then
                StrSql = " SELECT temp.DumId,temp.DumDate,temp.ItemId,CLRcode,Qty,MRP,temp.VendorId,I.ItemName,V.VendorName" & _
                         " FROM tTempPurchase temp, mpItem I, mpVendor V" & _
                         " WHERE temp.Status='A' AND temp.ItemId=I.ItemId AND temp.VendorId=V.VendorId " & _
                         " AND temp.VendorId=" & VendorNm
            ElseIf VendorNm = 0 And ItemNm <> "" Then
                StrSql = " SELECT temp.DumId,temp.DumDate,temp.ItemId,CLRcode,Qty,MRP,temp.VendorId,I.ItemName,V.VendorName" & _
                         " FROM tTempPurchase temp, mpItem I, mpVendor V" & _
                         " WHERE temp.Status='A' AND temp.ItemId=I.ItemId AND temp.VendorId=V.VendorId " & _
                         " AND I.ItemName like '%" & ItemNm & "%'"
            Else
                StrSql = " SELECT temp.DumId,temp.DumDate,temp.ItemId,CLRcode,Qty,MRP,temp.VendorId,I.ItemName,V.VendorName" & _
                         " FROM tTempPurchase temp, mpItem I, mpVendor V" & _
                         " WHERE temp.Status='A' AND temp.ItemId=I.ItemId AND temp.VendorId=V.VendorId " & _
                         " AND temp.VendorId=" & VendorNm & " AND I.ItemName like '%" & ItemNm & "%'"
            End If

            Return DbHelper.ExecuteDataTable(StrSql)
        Catch ex As Exception
            DGeneral.ErrorHandler(ex.Message, "DAL", "DTempPurchase", "GetRecords")
            Return Nothing
        End Try
    End Function


    Public Shared Function GetRecords(ByVal ItemNm As String) As DataTable
        Dim StrSql As String = ""
        Try

            StrSql = " SELECT temp.DumId,temp.DumDate,temp.ItemId,CLRcode,Qty,MRP,temp.VendorId,I.ItemName,V.VendorName" & _
                     " FROM tTempPurchase temp, mpItem I, mpVendor V" & _
                     " WHERE temp.Status='A' AND temp.ItemId=I.ItemId AND temp.VendorId=V.VendorId " & _
                     " AND I.ItemName like '%" & ItemNm & "%'"

            Return DbHelper.ExecuteDataTable(StrSql)
        Catch ex As Exception
            DGeneral.ErrorHandler(ex.Message, "DAL", "DTempPurchase", "GetRecords")
            Return Nothing
        End Try
    End Function

End Class
